﻿@{
    Layout = null;
}

                <div class="BlockContent Clear">
                    
                    <div  class="FormContainer VerticalFormContainer Clear" style="">
                        <dl>
                            @{var level = new int[] { 0, 1 };}
                            @if (Session["username"] == null)
                            {
                                <h3>Bạn cần 
                   <u><a href="javascript:;" onclick="javascript:loadAction('Login','Account')" style="color: #0000CC">đăng nhập</a></u>
                                    để bình luận
                                </h3>
                            }
                            else
                            {
                                <dt>
                                    <strong id="cmtUser">@Session["username"]</strong>
                                </dt>
                                <dd>
                                    <textarea id="cmtBody"></textarea>
                                    <a href="javascript:" onclick="javascript:sendComment(false,null)" class="myBtn1">Gửi bình luận</a>
                                </dd>
                            }
                            @foreach (var cmt in Model)
                            {
                            <dt>
                                <strong>@cmt.Key.Account.username</strong>
                                Ngày gửi: @cmt.Key.post_date
                            </dt>
                            <dd>
                                <p>@cmt.Key.body</p>
                                
                                @if(Session["userLevel"]!=null 
                                    && (level.Contains((int)Session["userLevel"]) || Session["username"].ToString().Equals(cmt.Key.Account.username)))
                                {
                                <a href="javascript:;" onclick="javascritpt:removeCmt(@cmt.Key.ID)" class="FloatRight">
                                    <img src="/Content/data/icon/cancel-icon.png" height="15" title="Xóa bình luận"/></a>                                                                 
                                }
                                @if(Session["username"] != null)
                                      {
                                          <a href="javascript:;" onclick="javascritpt:answerClick(@cmt.Key.ID)" style="color:#3300CC">Trả lời</a>
                                      }
                            </dd>
                                foreach (var rl in cmt.Value)
                                {
                                <dt class="cmt-reply">
                                    <strong>@rl.Account.username</strong>
                                    Ngày gửi: @rl.post_date
                                </dt>
                                <dd class="cmt-reply">
                                   <p>@rl.body</p> 
                                    @if(Session["userLevel"]!=null 
                                        && (level.Contains((int)Session["userLevel"]) || Session["username"].ToString().Equals(rl.Account.username)))
                                    {
                                    <a href="javascript:;" onclick="javascritpt:removeCmt(@rl.ID)" class="FloatRight">
                                    <img src="/Content/data/icon/cancel-icon.png" height="15" title="Xóa trả lời"/> </a>                                                                                                                                                 
                                    }
                                </dd>
                                }
                                if (Session["username"] != null)
                                {
                                <dt class="cmt-reply" id="rl-dt-@cmt.Key.ID" style="display:none">
                                    <strong>@Session["username"]</strong>
                                </dt>
                                <dd class="cmt-reply" id="rl-dd-@cmt.Key.ID" style="display:none">
                                    <textarea id="replyBody-@cmt.Key.ID" ></textarea>
                                    <a href="javascript:" onclick="javascript:sendComment(true,@cmt.Key.ID)" class="myBtn1">Trả lời</a>
                                </dd>
                                }
                            }                                                        
                        </dl>
                    </div>
                </div>
<div class="Clear"></div>



